package com.store.app.utils;

import android.text.TextUtils;
import android.util.Log;

/**
 * Created by Administrator on 2016/11/3.
 * 促销规则工具类
 */
public class DeductionUtils {
    //计算促销之后的价格

    /**
     *
     * @param price  促销之前的价格
     * @return 折扣之后的价格
     */
    public static String plan(String price){
        Log.v("zyl","优惠之前的价格："+price);
        //折扣规则有效
        if(SettingData.discountStatus.equals("enable")){
            if(TextUtils.isEmpty(SettingData.discount)){
                SettingData.discount = "0";
            }
           int dis = Integer.parseInt(SettingData.discount);
            Log.v("zyl","折扣值："+dis);
            int dex = 100 - dis;
            Log.v("zyl","100-折扣值："+dex);
            String pointIndex = MoneyUtil.moneydiv(dex+"","100");
            Log.v("zyl","计算出来的基数："+pointIndex);
            return MoneyUtil.moneyMul(price,pointIndex);
        }else{
            return price;
        }
    }

}
